/**
 * Created by Administrator on 2017/5/22.
 */
/**
 * Created by Administrator on 2017/5/22.
 */
module.exports = function (sequelize, DataTypes) {
    var _model = sequelize.define("userProject", {
        id: {type: DataTypes.UUID, primaryKey: true, comment: '任务ID'}
        ,
        teamid: {
            type:DataTypes.STRING(100), comment: '团队 ID', references: {
                model: sequelize.models.team
                , key:'teamid'
            }
        }
        , userid: {
            type:DataTypes.STRING(100), comment: '用户ID', references: {
                model: sequelize.models.user
                , key:'userid'
            }
        }
        , title: {type: DataTypes.STRING(50), comment: '职位名称'}
        , principal: {type: DataTypes.STRING(150), comment: '负责的职责'}
        , inform: {type: DataTypes.INTEGER,  comment: '通知条数'}
        , inform_content:{type:DataTypes.TEXT("long"),defaultValue:"", comment: '通知内容'}
        , listid: {type: DataTypes.UUID, comment: '笔记本',references: {
            model: sequelize.models.notes
            , key: 'listid'
        }}
        , ext: {type: DataTypes.TEXT("long"), comment: '扩展字段'}
    }, {
        indexes: [ {
            name: 'teamid'
            , fields: ['teamid']
        }, {
            name: 'userid'
            , fields: ['userid']
        }]
        , classMethods: {
            associate: function (models) {
                _model.belongsTo(models.user, {foreignKey: 'userid'});
                _model.belongsTo(models.team, {foreignKey: 'teamid'});
                _model.belongsTo(models.notes, {foreignKey: 'listid'});
            }
        }
    });
    return _model;
};